package com.atguigu.tingshu.order.pattern.factory;

import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.order.pattern.PayStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * ClassName : PayStrategyFactory
 * Package : com.atguigu.tingshu.order.pattern.factory
 * Description :
 * <p>
 * Author: LHZ
 * Create: 2025/8/4 15:34
 * Version: 1.0
 */
@Slf4j
@SuppressWarnings("all")
@Component
public class PayStrategyFactory {

    @Autowired
    private Map<String, PayStrategy> map;

    public PayStrategy getPayStraategy(String type){
        if(map.containsKey(type)){
            return map.get(type);
        }
        log.error("不包含此类型:{}",type);
        throw new GuiguException(500,"不包含此类型");
    }

}